package com.sumainfor.pc.market.controller.jianrongjiayuan;



import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class MessageTool {

	// 签到交易获取sessionKey
	public static String getQiandaoMessage(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038BDC"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038BDC</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"</message>\n";

		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
	}

	// 行政区域查询
	public static String getXingzhengMessage(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();
		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMA2"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMA2</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <CSID>310000</CSID>\n"+
						"  </body>\n"+
						"</message>\n";

		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
	}

	// 图片上传
	public static String getFilePathMessage(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();
		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMM1"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMM1</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <SCLX>2</SCLX>\n"+
						"    <JTDZ>http://tangchaoroom.net/FrMhdE7cm6ohWqkSadcI8zA2BpCT</JTDZ>\n"+
						"  </body>\n"+
						"</message>\n";
		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
	}

	// 创建门店
	public static String createShop(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMP1"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMP1</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <CSID>310000</CSID>\n"+
						"    <XMMC>唐巢公寓门店</XMMC>\n"+
						"    <SFBH>TC0002</SFBH>\n"+
						"    <XMLX>2</XMLX>\n"+
						"    <KFDH>400-8202692</KFDH>\n"+
						"    <FMTP>/upload/668/39f290f6-7d5c-f79d-7ed9-3a8a7e4c8fac.png</FMTP>\n"+
						"    <JSTP>[\"/upload/668/39f290f6-7d5c-f79d-7ed9-3a8a7e4c8fac.png\",\"/upload/668/39f290f6-7d5c-f79d-7ed9-3a8a7e4c8fac.png\"]</JSTP>\n"+
						"    <ZSBQ>上海,唐巢,公寓</ZSBQ>\n"+
						"  </body>\n"+
						"</message>\n";
		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;

		/**
		 *
		 * <XMBH>39f27c2e-6c5a-01bb-a74c-ec6709078aac</XMBH> 门店编码
		 * <XMMC>唐巢公寓</XMMC> 门店名称
		 * <SFBH>TC0001</SFBH> 接入方门店编码
		 */
	}

	// 小区对齐
	public static String getCommunityMessage(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMA1"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMA1</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <CSID>310000</CSID>\n"+
						"    <DSFQ>唐丰苑</DSFQ>\n"+
						"    <QYID>310115</QYID>\n"+
						"  </body>\n"+
						"</message>\n";
		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
		/**
		 *<XQID>39f16fb2-9922-2f78-a267-7e2b5e892e21</XQID>
		 *<XQMC>唐丰苑</XQMC>
		 *<XQDZ>浦东新区创新西路333弄</XQDZ>
		 *<WZJD>121.648024</WZJD>
		 *<WZWD>31.202047</WZWD>
		 */
	}

	// 创建房间
	public static String createHouse(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMH5"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMH5</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>999999</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <XMBH>39f27c2e-6c5a-01bb-a74c-ec6709078aac</XMBH>\n"+ //门店id
						"    <XQID>39f16fb2-9922-2f78-a267-7e2b5e892e21</XQID>\n"+ //小区id
						"    <LYBH>0000000000000000001</LYBH>\n"+ //房间id 最大60字符
						"    <LDMC>011</LDMC>\n"+ //楼号
						"    <DYMC>2</DYMC>\n"+ //单元
						"    <LCMC>3</LCMC>\n"+ //所在楼层
						"    <FJHM>A302</FJHM>\n"+ //房间号 1-10个全数字或A-Z开头加1-9个数字
						"    <LDZL>6</LDZL>\n"+ //总楼层
						"    <FJGF>2</FJGF>\n"+ //几房
						"    <FJGT>1</FJGT>\n"+ //几厅
						"    <FJGW>1</FJGW>\n"+ //几卫
						"    <FJGC>1</FJGC>\n"+ //几厨
						"    <FJGY>1</FJGY>\n"+ //阳台
						"    <CHTY>-1</CHTY>\n"+ //窗户类型 -1未知
						"    <BZZJ>1800</BZZJ>\n"+ //租金
						"    <JZMJ>48</JZMJ>\n"+ //面积
						"    <TWXX>精品好房，租到就是赚到</TWXX>\n"+ //房间描述，非必填
						"    <LXDH>15821512092</LXDH>\n"+ //联系电话，5-11位字符长度
						"    <GRSS>电视、冰箱、洗衣机</GRSS>\n"+ //房间设施，非必填，例 电视、冰箱、洗衣机，、号分割
						"    <FJZT>1</FJZT>\n"+ //0-已下架（不可租）、1-已上架（空闲可租）、6-已出租（外部出租）
						"    <JSTP>[{\"url\":\"/upload/668/39f2785e-cda0-0541-4397-28b2f48f1396.jpg\",\"title\":\"卧室\"},{\"url\":\"/upload/668/39f27c52-8750-6262-1644-04a5ca969997.jpg\",\"title\":\"客厅\"},{\"url\":\"/upload/668/39f27c52-3bd4-e8fa-29ae-890515f3ba2b.jpg\",\"title\":\"厨房\"},{\"url\":\"/upload/668/39f27c51-bcd8-7044-1b9a-25ba1766e106.jpg\",\"title\":\"卫生间\"},{\"url\":\"/upload/668/39f27c51-33ef-57ef-857f-58fd44282c10.jpg\",\"title\":\"阳台\"}]</JSTP>\n"+ //JSON格式，如：[{"url":"建融公寓图片路径","title":"主卧"}]，可支持至少5张，最多20张图片。图片网址必须转换为建融公寓图片地址，修改到此字段时需要进行图片审核，无修改则不审核。
						"    <TJBQ>近地铁,独卫</TJBQ>\n"+ //推荐标签，例 近地铁,独卫
						"  </body>\n"+
						"</message>\n";
		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
		// <HZBH>39f27c53-cc4b-b638-c910-9a83b6a838a2</HZBH> 建融平台房间id
		// <HZBH>39f27c54-f00e-c632-6df0-0404bfea6fab</HZBH>
	}

	// 房源上下架 出租或下架后，通知建融更新房源状态
	public static String houseUpOrDown(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signReqMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0200</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000MF</LH_REQ_SYS_NO>\n"+ //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+
						"    <LH_REQUEST_FLOW_NO>A3038HMU1"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+
						"    <LH_TRAN_CD>A3038HMU1</LH_TRAN_CD>\n"+
						"    <LH_PROV_NO>999999</LH_PROV_NO>\n"+  //实际省的行政区划代码
						"    <LH_CITY_NO>310000</LH_CITY_NO>\n"+  //实际城市的行政区划代码
						"  </head>\n"+
						"  <body>\n"+
						"    <APPID>KQFPBI1XO3KR3JXM</APPID>\n"+
						"    <FJBH>39f27c53-cc4b-b638-c910-9a83b6a838a2</FJBH>\n"+
						"    <XMBH>39f27c2e-6c5a-01bb-a74c-ec6709078aac</XMBH>\n"+
						"    <FJZT>1</FJZT>\n"+ // "0-下架（不可租）、1-上架（空闲可租）、6-已出租（外部出租）如果当前房源已在建融公寓平台出租或预定，则无法进行上下架操作"
						"  </body>\n"+
						"</message>\n";
		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signReqMessage.replaceAll("\n", "\r\n");
		else
			return signReqMessage;
	}

	public static String getSignRetMessage(){
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
		Calendar calendar = Calendar.getInstance();

		String signRetMessage =
				"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
						"<message>\n"+
						"  <head>\n"+
						"    <LH_VERSION>100</LH_VERSION>\n"+
						"    <LH_TYPE>0210</LH_TYPE>\n"+
						"    <LH_REQ_SYS_NO>000000M1</LH_REQ_SYS_NO>\n"+  //实际分配的接入系统编码
						"    <LH_RES_SYS_NO>A3031</LH_RES_SYS_NO>\n"+
						"    <LH_FORWARD_FLAG>0</LH_FORWARD_FLAG>\n"+
						"    <LH_REQUEST_DATE>"+df.format(calendar.getTime()).substring(0,8)+"</LH_REQUEST_DATE>\n"+      //实际取请求报文中的字段值返回
						"    <LH_REQUEST_TIME>"+df.format(calendar.getTime()).substring(8,14)+"</LH_REQUEST_TIME>\n"+     //实际取请求报文中的字段值返回
						"    <LH_REQUEST_FLOW_NO>A3038BDC"+Long.toString(new Date().getTime())+"</LH_REQUEST_FLOW_NO>\n"+ //实际取请求报文中的字段值返回
						"    <LH_RESPONSE_STATUS>00</LH_RESPONSE_STATUS>\n"+
						"    <LH_RESPONSE_CODE>000000000000</LH_RESPONSE_CODE>\n"+
						"    <LH_RESPONSE_MSG>签到成功</LH_RESPONSE_MSG>\n"+
						"  </head>\n"+
						"  <body>\n"+
						"    <HandKey>%s</HandKey>\n"+
						"  </body>\n"+
						"</message>\n";

		if(System.getProperty("os.name").indexOf("windows")>=0)
			return signRetMessage.replaceAll("\n", "\r\n");
		else
			return signRetMessage;
	}
}
